<template>
  <view class="index-page">
    <view class="top-wrapper">
      <view class="top-wrapper-box">
        <view>
          <view class="top-wrapper-info">
            <view class="top-wrapper-info-text">深圳·松阳基地</view>
          </view>
          <view class="top-wrapper-info2">种植批次：暂无种植记录</view>
        </view>
        <view class="intro-btn">基地介绍</view>
      </view>
    </view>
    <view class="main-wrapper">
      <view class="action-wrapper">
        <view
          v-for="(item, index) in actionTabs"
          :key="index"
          @click="gotoPage(item)"
          class="action-wrapper-item"
        >
          <view class="action-wrapper-item-icons">
            <image
              :src="item.pic"
              mode="widthFix"
              class="action-wrapper-item-icon"
            ></image>
          </view>
          <view class="action-wrapper-item-text">{{ item.name }}</view>
        </view>
      </view>
      <view class="category-wrapper">
        <view
          v-for="(item, index) in actionCategory"
          :key="index"
          @click="gotoPage(item)"
          class="category-wrapper-item"
        >
          <image
            :src="item.pic"
            mode="widthFix"
            class="category-wrapper-item-icon"
          ></image>
          <view class="category-wrapper-item-text">{{ item.name }}</view>
        </view>
      </view>
      <view class="scrollview-wrapper">
        <scroll-view scrollX class="scrollview">
          <view
            @click="gotoPage(item)"
            v-for="(item, index) in advertising"
            :key="index"
            class="scrollview-wrapper-item"
          >
            <image class="scrollview-wrapper-item-pic" :src="item.pic"></image>
          </view>
        </scroll-view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      actionTabs: [
        {
          pic: require("@/static/img/index-icon.png"),
          name: "用药兑水",
          path: "/pages/medicated-water/index",
        },
        {
          pic: require("@/static/img/index-icon2.png"),
          name: "识别病虫",
          path: "/pages/discern/index",
        },
        {
          pic: require("@/static/img/index-icon3.png"),
          name: "田间试验",
          path: "/pages/experiment/index",
        },
        {
          pic: require("@/static/img/index-icon4.png"),
          name: "水源管理",
          path: "/pages/headwaters/index",
        },
      ],
      actionCategory: [
        {
          pic: require("@/static/img/index-icon5.png"),
          name: "种植管理",
          path: "/pages/farming-admin/index",
        },
        {
          pic: require("@/static/img/index-icon6.png"),
          name: "农事管理",
        },
        {
          pic: require("@/static/img/index-icon7.png"),
          name: "基地及农产品监管",
        },
        {
          pic: require("@/static/img/index-icon8.png"),
          name: "农机管理",
        },
        {
          pic: require("@/static/img/index-icon9.png"),
          name: "投入品管理",
        },
        {
          pic: require("@/static/img/index-icon10.png"),
          name: "稻谷信息化生产管理",
        },
        {
          pic: require("@/static/img/index-icon11.png"),
          name: "大米信息化生产管理",
        },
        {
          pic: require("@/static/img/index-icon12.png"),
          name: "农技服务和推广",
          path: "/pages/promotion/index",
        },
      ],
      advertising: [
        {
          pic: require("@/static/img/index-advertising.png"),
          path: "/pages/monitor/crop",
        },
        {
          pic: require("@/static/img/index-advertising2.png"),
          path: "/pages/monitor/index",
        },
        {
          pic: require("@/static/img/index-advertising3.png"),
          path: "/pages/monitor/trace",
        },
      ],
    };
  },
  onLoad() {},
  methods: {
    gotoPage(item) {
      console.log(item.path);
      item.path &&
        uni.navigateTo({
          url: item.path,
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.index-page {
  width: 100%;
  position: relative;
  background: #f6f6f6;
  min-height: 100vh;
  padding-bottom: 80rpx;
}
.top-wrapper-box {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-end;
}
.intro-btn {
  width: 123rpx;
  height: 44rpx;
  line-height: 44rpx;
  background: rgba(255, 255, 255, 0.29);
  border-radius: 53rpx;
  font-size: 21rpx;
  font-weight: bold;
  color: #ffffff;
  text-align: center;
}
.top-wrapper {
  width: 100%;
  height: 405rpx;
  background: #1ac678;
  opacity: 1;
  overflow: hidden;
  padding: 140rpx 35rpx 0;

  &-info {
    display: flex;
    margin-bottom: 21rpx;
  }

  &-info2 {
    color: #fff;
    font-size: 21rpx;
    font-weight: 400;
  }
  &-info-text {
    color: #fff;
    font-size: 32rpx;
    font-weight: bold;
  }
}
.main-wrapper {
  position: relative;
  top: -108rpx;
}
.action-wrapper {
  width: 690rpx;
  height: 216rpx;
  background: #ffffff;
  border-radius: 14rpx;
  opacity: 1;
  margin: 0 auto;
  display: flex;
  flex-direction: row;
  margin-bottom: 25rpx;
  &-item {
    width: 25%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    &-text {
      font-size: 26rpx;
      font-weight: bold;
      color: #202020;
    }
    &-icons {
      display: flex;
      align-items: center;
      height: 61rpx;
      margin-bottom: 21rpx;
    }
    &-icon {
      width: 59rpx;
      opacity: 1;
    }
  }
}
.category-wrapper {
  background: #ffffff;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  margin-bottom: 37rpx;
  &-item {
    width: 50%;
    height: 142rpx;
    border: 2rpx solid #e9e9e9;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0 35rpx;
    &-text {
      width: 210rpx;
      font-size: 26rpx;
      font-weight: bold;
      color: #202020;
      // text-align: center;
    }
    &-icon {
      width: 80rpx;
      height: 80rpx;
      opacity: 1;
      margin-right: 21rpx;
    }
  }
}
.scrollview {
  white-space: nowrap;
  ::-webkit-scrollbar {
    display: none;
  }
}
.scrollview-wrapper {
  padding-left: 20px;
  &-item {
    display: inline-block;
    width: 315rpx;
    height: 193rpx;
    background: #d9f1e1;
    border-radius: 14rpx;
    opacity: 1;
    margin-right: 18rpx;
    &-pic {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
